﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using System.Windows.Media;

namespace wms_wpf.Converter
{
    public class GroupNumberToColorConverter : IValueConverter
    {
        private readonly Color[] colors = { Colors.Red, Colors.Green, Colors.Blue, Colors.Silver, Colors.BlueViolet,
                                            Colors.CadetBlue,Colors.Chartreuse,Colors.Cornsilk,Colors.DarkCyan,Colors.DarkGoldenrod,
                                            Colors.HotPink ,Colors.Ivory,Colors.Lavender,Colors.OrangeRed,Colors.Olive,Colors.Purple,
                                            Colors.PaleGreen, Colors.PaleTurquoise, Colors.PaleVioletRed,Colors.Peru,Colors.Snow,Colors.Tan,
                                            Colors.Thistle,Colors.Violet};

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is int groupNumber && groupNumber >= 1 && groupNumber <= 200)
            {
                int colorIndex = groupNumber % colors.Length; // 确保颜色不重复
                return new SolidColorBrush(colors[colorIndex]);
             
            }
            else
            {
                return Brushes.Black; // 默认颜色，当GroupNumber超出范围时使用
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
